﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Server;
using System.Net;
using Newtonsoft.Json;

namespace BaiduAPI.Weather
{
    /// <summary>
    /// 天气服务 只能在本程序当中使用
    /// </summary>
    internal class WeatherService
    {
        /// <summary>
        /// 根据城市的拼音获取天气情况
        /// </summary>
        /// <returns></returns>
        public static WeatherClass get_FromCityPinYin(string strCode)
        {
            string strAddress = APIAddress.Weather + "?citypinyin={0}";
            return WebInvoke<WeatherClass>.Invoke(string.Format(strAddress, strCode));
        }

        /// <summary>
        /// 根据城市的名称获取天气情况
        /// </summary>
        /// <returns></returns>
        public static WeatherClass get_FromCityName(string strCode)
        {
            string strAddress = APIAddress.Weather + "?cityname={0}";
            return WebInvoke<WeatherClass>.Invoke(string.Format(strAddress, strCode));
        }

        /// <summary>
        /// 根据城市的编号获取天气的情况
        /// </summary>
        /// <returns></returns>
        public static WeatherClass get_FormCityNo(string strCode)
        {
            string strAddress = APIAddress.Weather + "?cityid={0}";
            return WebInvoke<WeatherClass>.Invoke(string.Format(strAddress, strCode));
        }


    }
}
